<?php

class Application_Model_PicturesNewService
extends Application_Model_BaseService
{
    protected  $dbTableName = 'Application_Model_DbTable_PicturesNew';
    protected $modelName = 'Application_Model_PictureNew';
	private    static $instance = null;
    
    public static function getInstance(){
        if (Application_Model_NewsService::$instance == null)
            Application_Model_NewsService::$instance = 
                new Application_Model_NewsService();
        
        return Application_Model_NewsService::$instance;
    }
    
    public function findByNewId($newId = null){
        if ($newId != null){
            $res = $this->getDbTable()->fetchAll(
                $this ->getDbTable()
                         ->select()
                         ->where('pictures_new.new_id = ?', $newId)
            );
            if (count($res) == 0){
                return null;
            }
            return $res-> toArray(); 
        } else {
            return null;
        }
    }
    
    public function getPaginatorRows ($pageNumber = 1)
	{
		$paginator = new Zend_Paginator(
            new Zend_Paginator_Adapter_DbSelect(
                $this   ->getDbTable()
                        ->select()
                        ->order('date_create DESC')                        
            )
        );
        
		$paginator->setCurrentPageNumber($pageNumber);
		$paginator->setItemCountPerPage(5);
		$paginator->setPageRange(3);
		return $paginator;
	}
    //-------------
}

